import { ResPage, Goods } from "@/api/interface/index";
import { Merchant } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 订单管理模块
 */
// 获取订单列表
export const getMerchantOrders = (params: Goods.ReqGoodsParams) => {
  return http.post<ResPage<Goods.ResGoodsList>>(Merchant + `order/list`, params);
};

/**
 * @name 订单管理模块
 */
// 获取订单列表
export const getPublishedGoodsList = (params: Goods.ReqGoodsParams) => {
  return http.post<ResPage<Goods.ResGoodsList>>(Merchant + `goods/published`, params);
};

// 获取树形订单列表
export const getUserTreeList = (params: Goods.ReqGoodsParams) => {
  return http.post<ResPage<Goods.ResGoodsList>>(Merchant + `user/tree`, params);
};

// 新增订单
export const addUser = (params: { id: string }) => {
  return http.post(Merchant + `/user/add`, params);
};

// 批量添加订单
export const BatchAddUser = (params: FormData) => {
  return http.post(Merchant + `/user/import`, params);
};

// 编辑订单
export const editProduct = (params: { id: string }) => {
  return http.post(Merchant + `goods/edit`, params);
};

// 删除订单
export const deleteUser = (params: { id: string[] }) => {
  return http.post(Merchant + `/user/delete`, params);
};

// 切换订单状态
export const changeUserStatus = (params: { id: string; status: number }) => {
  return http.post(Merchant + `/user/change`, params);
};

// 重置订单密码
export const publishGoods = (params: { item_id: string }) => {
  return http.post(Merchant + `goods/publish`, params);
};

export const removeGoods = (params: { item_id: string }) => {
  return http.post(Merchant + `goods/remove`, params);
};

export const recoverGoods = (params: { item_id: string }) => {
  return http.post(Merchant + `goods/recover`, params);
};

// 导出订单数据
export const exportUserInfo = (params: Goods.ReqGoodsParams) => {
  return http.download(Merchant + `/user/export`, params);
};

// 获取订单状态字典
export const getGoodsStatus = () => {
  return http.get<Goods.ResStatus[]>(Merchant + `dict/status`);
};
